package day019.homework.p4;

import java.io.File;
import java.io.IOException;
import java.util.Scanner;

public class FileTest1 {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入文件路径名称：");
        String file = sc.nextLine();
        show(file);
    }

    public static void show(String filePath) throws IOException {
        File f = new File(filePath);
        if (!f.exists()) {
            f.createNewFile();
        } else {
            System.out.println("文件名：" + f.getName());
            System.out.println("绝对路径：" + f.getAbsolutePath());
            System.out.println("父路径：" + f.getParent());
            System.out.println("文件大小：" + f.length());
            System.out.println("文件后缀名：" + f.getName().substring(f.getName().lastIndexOf(".") + 1));
        }
    }
}
